import request from '@/utils/request'
import {PAGE_SIZES} from "@/utils/common";

export function getAllOrderList(limit, page) {
  return request({
    url: `table/list/${limit}/${page}`,
    method: 'get'
  })
}

export function getMyCreatedOrderList(limit, page, params) {
  return request({
    url: `table/find/my/created/${limit}/${page}`,
    method: 'get',
    params
  })
}

export function getMyHandlingOrderList(limit, page) {
  return request({
    url: `table/find/my/handling/${limit}/${page}`,
    method: 'get'
  })
}

export function getMyOrderList(limit, page) {
  return request({
    url: `table/find/my/${limit}/${page}`,
    method: 'get'
  })
}

export function getFreeOrder(limit, page, params) {
  return request({
    url: `table/store/list/${limit}/${page}`,
    method: 'get',
    params
  })
}

export function copyTemplate(aid, data) {
  return request({
    url: `table/assembly/copy/${aid}`,
    method: 'POST',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}

export function modifyOrder(tid, data) {
  return request({
    url: `table/fill/head/${tid}`,
    method: 'POST',
    data
  })
}

export function deleteCheck(tid, oid, sign) {
  return request({
    url: `table/${tid}/${oid}/${sign}`,
    method: 'DELETE'
  })
}

export function getCheckTime(tid) {
  return request({
    url: `table/${tid}/checktime`,
    method: 'GET'
  })
}

export function getProblemOrder(pid, limit, page, params) {
  return request({
    url: `table/problem/${pid}/list/${limit}/${page}`,
    method: 'GET',
    params
  })
}

export function countList(data) {
  return request({
    url: `table/data/check/tables`,
    method: 'POST',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}

export function setMainOrder(tid, ftid) {
  return request({
    url: `table/setto/${tid}`,
    method: 'POST',
    params: {
      ftid
    }
  })
}

export function getOrderSetByMainOrder(tid, page, limit = PAGE_SIZES) {
  return request({
    url: `/table/find/byMainOrder/${tid}/${limit}/${page}`,
    method: 'GET'
  })
}
